﻿using System;
using System.Collections.Generic;
using Helpers;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.LogEntries
{
	// Token: 0x020002C9 RID: 713
	public class BesiegeSettlementLogEntry : LogEntry, IEncyclopediaLog, IChatNotification, IWarLog
	{
		// Token: 0x06002A11 RID: 10769 RVA: 0x000B425A File Offset: 0x000B245A
		internal static void AutoGeneratedStaticCollectObjectsBesiegeSettlementLogEntry(object o, List<object> collectedObjects)
		{
			((BesiegeSettlementLogEntry)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
		}

		// Token: 0x06002A12 RID: 10770 RVA: 0x000B4268 File Offset: 0x000B2468
		protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
		{
			base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			collectedObjects.Add(this.BesiegerHero);
			collectedObjects.Add(this.Settlement);
			collectedObjects.Add(this.BesiegerFaction);
		}

		// Token: 0x06002A13 RID: 10771 RVA: 0x000B4295 File Offset: 0x000B2495
		internal static object AutoGeneratedGetMemberValueBesiegerHero(object o)
		{
			return ((BesiegeSettlementLogEntry)o).BesiegerHero;
		}

		// Token: 0x06002A14 RID: 10772 RVA: 0x000B42A2 File Offset: 0x000B24A2
		internal static object AutoGeneratedGetMemberValueSettlement(object o)
		{
			return ((BesiegeSettlementLogEntry)o).Settlement;
		}

		// Token: 0x06002A15 RID: 10773 RVA: 0x000B42AF File Offset: 0x000B24AF
		internal static object AutoGeneratedGetMemberValueBesiegerFaction(object o)
		{
			return ((BesiegeSettlementLogEntry)o).BesiegerFaction;
		}

		// Token: 0x06002A16 RID: 10774 RVA: 0x000B42BC File Offset: 0x000B24BC
		internal static object AutoGeneratedGetMemberValue_isBesiegerArmy(object o)
		{
			return ((BesiegeSettlementLogEntry)o)._isBesiegerArmy;
		}

		// Token: 0x17000A78 RID: 2680
		// (get) Token: 0x06002A17 RID: 10775 RVA: 0x000B42CE File Offset: 0x000B24CE
		public bool IsVisibleNotification
		{
			get
			{
				return true;
			}
		}

		// Token: 0x06002A18 RID: 10776 RVA: 0x000B42D1 File Offset: 0x000B24D1
		public BesiegeSettlementLogEntry(MobileParty besiegerParty, Settlement settlement)
		{
			this.BesiegerHero = besiegerParty.Party.Owner;
			this.Settlement = settlement;
			this._isBesiegerArmy = (besiegerParty.Army != null);
			this.BesiegerFaction = besiegerParty.MapFaction;
		}

		// Token: 0x06002A19 RID: 10777 RVA: 0x000B430C File Offset: 0x000B250C
		public override string ToString()
		{
			return this.GetEncyclopediaText().ToString();
		}

		// Token: 0x06002A1A RID: 10778 RVA: 0x000B431C File Offset: 0x000B251C
		public bool IsRelatedToWar(StanceLink stance, out IFaction effector, out IFaction effected)
		{
			IFaction faction = stance.Faction1;
			IFaction faction2 = stance.Faction2;
			effector = this.BesiegerFaction;
			effected = this.Settlement.MapFaction;
			return (this.BesiegerFaction == faction && this.Settlement.MapFaction == faction2) || (this.BesiegerFaction == faction2 && this.Settlement.MapFaction == faction);
		}

		// Token: 0x06002A1B RID: 10779 RVA: 0x000B437E File Offset: 0x000B257E
		public TextObject GetNotificationText()
		{
			TextObject textObject = new TextObject("{=E20BBKYo}{TOWN_NAME} has been besieged by {FACTION_NAME}.", null);
			textObject.SetTextVariable("TOWN_NAME", this.Settlement.EncyclopediaLinkWithName);
			textObject.SetTextVariable("FACTION_NAME", this.BesiegerFaction.EncyclopediaLinkWithName);
			return textObject;
		}

		// Token: 0x06002A1C RID: 10780 RVA: 0x000B43B9 File Offset: 0x000B25B9
		public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
		{
			return obj == this.BesiegerHero || obj == this.Settlement;
		}

		// Token: 0x06002A1D RID: 10781 RVA: 0x000B43DC File Offset: 0x000B25DC
		public TextObject GetEncyclopediaText()
		{
			TextObject textObject;
			if (this._isBesiegerArmy)
			{
				textObject = GameTexts.FindText("str_army_besieging_news_with_link", null);
			}
			else
			{
				textObject = GameTexts.FindText("str_party_besieging_news_with_link", null);
			}
			textObject.SetTextVariable("TOWN_NAME", this.Settlement.EncyclopediaLinkWithName);
			textObject.SetTextVariable("FACTION_NAME", this.BesiegerFaction.EncyclopediaLinkWithName);
			StringHelpers.SetCharacterProperties("LORD", this.BesiegerHero.CharacterObject, textObject, false);
			return textObject;
		}

		// Token: 0x04000CA7 RID: 3239
		[SaveableField(50)]
		public readonly Hero BesiegerHero;

		// Token: 0x04000CA8 RID: 3240
		[SaveableField(51)]
		public readonly Settlement Settlement;

		// Token: 0x04000CA9 RID: 3241
		[SaveableField(53)]
		public readonly IFaction BesiegerFaction;

		// Token: 0x04000CAA RID: 3242
		[SaveableField(54)]
		private readonly bool _isBesiegerArmy;
	}
}
